package com.lagou.edu.vo;

import java.io.Serializable;

/**
 * @ClassName: ResultInfo
 * @Auther: Jerry
 * @Date: 2020/7/19 13:30
 * @Desctiption: TODO
 * @Version: 1.0
 */
public class ResultInfo implements Serializable {

    private String msg;
    private Object data;
    private Integer code;

    public ResultInfo() {
    }

    public ResultInfo(String msg, Object data, Integer code) {
        this.msg = msg;
        this.data = data;
        this.code = code;
    }

    public static ResultInfo success(Object data){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setCode(200);
        resultInfo.setData(data);
        resultInfo.setMsg("success");
        return resultInfo;
    }

    public static ResultInfo success(String msg){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setCode(200);
        resultInfo.setMsg(msg);
        return resultInfo;
    }

    public static ResultInfo success(Object data, String msg){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setCode(200);
        resultInfo.setData(data);
        resultInfo.setMsg(msg);
        return resultInfo;
    }

    public static ResultInfo error(String msg){
        ResultInfo resultInfo = new ResultInfo();
        resultInfo.setMsg(msg);
        resultInfo.setCode(400);
        return resultInfo;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
